package org.example.stream;

import org.example.entity.Fruit;

import java.util.stream.Stream;

public class Stream03 {
    /**
     * 合并流
     */
    public static void main(String[] args) {
        Stream<Fruit> fruitStream1 = Stream.of(
                new Fruit("草莓", "Strawberry", "浆果", "红色"),
                new Fruit("桑葚", "Mulberry", "浆果", "紫色"),
                new Fruit("杨梅", "Wax-berry", "浆果", "红色")
        );

        Stream<Fruit> fruitStream2 = Stream.of(
                new Fruit("核桃", "Walnut", "坚果", "棕色"),
                new Fruit("花生", "Peanut", "坚果", "棕色"),
                new Fruit("蓝莓", "Blueberry", "浆果", "蓝色")
        );

        Stream.concat(fruitStream1, fruitStream2).forEach(System.out::println);

        System.out.println("--------------");
        Stream.of(
                new Fruit("草莓", "Strawberry", "浆果", "红色"),
                new Fruit("桑葚", "Mulberry", "浆果", "紫色"),
                new Fruit("杨梅", "Wax-berry", "浆果", "红色"),
                new Fruit("核桃", "Walnut", "坚果", "棕色"),
                new Fruit("花生", "Peanut", "坚果", "棕色"),
                new Fruit("蓝莓", "Blueberry", "浆果", "蓝色")
                // 注意：这里的条件可以写多个
        ).skip(1).limit(2).forEach(System.out::println);


    }
}
